package com.api.gbhg.luoao.web;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.api.gbhg.liuwenbo.dao.ProjectDetailsUtil;
import com.api.gbhg.liuwenbo.utils.FormatUtil;
import com.api.gbhg.luoao.tool.ToolCURD;
import com.api.gbhg.luoao.utils.Headquarters;
import com.api.gbhg.luoao.utils.ProcesscontentUtils;
import com.api.gbhg.zengping.dao.PropertyManagementCostDao;
import weaver.conn.RecordSet;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;

/**
 * 获取预算信息
 *
 */
@Path("/ps")
public class Processcontent {

    @POST
    @Path("/getBudgetinformation")
    @Produces(MediaType.APPLICATION_JSON)
    public String getProcessinformation(Map<String,Object> param) {
        Map<String,Object> map =new HashMap<>();

            map.put("requestId",param.getOrDefault("requestId","").toString());
            RecordSet rs = new RecordSet();
            rs.executeQuery("select kmk.kmc,fei.dj,fei.syed,fei.ze from uf_jingfei fei,uf_jjzcflkmk kmk " +
                    "where fei.requestId = " + param.getOrDefault("requestId","").toString()
                    + " and fei.bmzcjjfl = kmk.kdm and fei.bmzcjjfl ="+param.getOrDefault("bmjjflid","").toString());

        BigDecimal dj = new BigDecimal("0.00");
        BigDecimal syed = new BigDecimal("0.00");
        BigDecimal ze = new BigDecimal("0.00");
            while (rs.next()) {
                map.put("kmc",  rs.getStringNoTrim("kmc"));//经济分类
                dj =dj.add(new BigDecimal(rs.getString("dj")));
                syed =syed.add(new BigDecimal(rs.getString("syed")));
                ze = ze.add(new BigDecimal(rs.getString("ze")));
            }

            map.put("dj",dj);//冻结金额
            map.put("syed",syed);//剩余金额
            map.put("yszje",ze);//总金额


            BigDecimal ysy = new BigDecimal("0.00");
            if (ze.compareTo(syed) == 1) {
                ysy = ToolCURD.sub(ze,syed).subtract(dj);
            }
            map.put("yyje", ysy.toString());//已使用

        return JSON.toJSONString(map);


    }






}
